package cn.shengongying.api.vo;

import cn.shengongying.model.BossPosition;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * author: RXK
 * date: 2022/1/7 星期五
 * desc:
 */
@Getter
@Setter
@ApiModel(value = "职位信息")
public class BossPositionDetailVo extends PositionVo {
    private static final long serialVersionUID = -757982867347602543L;


    @ApiModelProperty(value = "状态(0:关闭;1:启用)")
    private Integer status;


    @ApiModelProperty(value = "开工时间(兼职、临工)")
    private Long startTime;

    /**
     * 结束时间
     */
    @ApiModelProperty(value = "结束时间(兼职、临工)(时间戳)")
    private Long endTime;

    /**
     * 班别类型(0:白班;1:夜班)
     */
    @ApiModelProperty(value = "班别类型(0:白班;1:夜班)(时间戳)")
    private Integer workTimeType;

    /**
     * 薪资类型(-1:面议;0:小时;1:天;2:按产品报价;3:月)
     */
    @ApiModelProperty(value = "薪资类型((-1:面议;0:小时;1:天;2:按产品报价;3:月))")
    private Integer salaryType;

    /**
     * 薪水(x元/小时、x元/小时)
     */
    @ApiModelProperty(value = "(最小/最低)薪资金额(xxxx元)")
    private Integer salary;

    /**
     * 最大薪水
     */
    @ApiModelProperty(value = "最大薪资金额")
    private Integer maxSalary;

    /**
     * 工作时长
     */
    @ApiModelProperty(value = "工作时长")
    private Integer workHour;

    /**
     * 福利类型(0:包吃住;1:包住不包吃;3:包吃不包住;4:有夜宵;5:包住有餐补;6:包吃有房补)(2,3,4,5多选类型)
     */
    @ApiModelProperty(value = "福利类型(0:包吃住;1:包住不包吃;3:包吃不包住;4:有夜宵;5:包住有餐补;6:包吃有房补)(2,3,4,5逗号分割多选类型)")
    private String benefits;

    /**
     * 性别(0:男;1:女)
     */
    @ApiModelProperty(value = "性别(0:男;1:女)")
    private Integer sex;

    /**
     * 年龄最小值
     */
    @ApiModelProperty(value = "年龄最小值")
    private Integer minAge;

    /**
     * 年龄最大值
     */
    @ApiModelProperty(value = "年龄最大值")
    private Integer maxAge;

    /**
     * 教育背景(0:高中;1:大专;2:本科)
     */
    @ApiModelProperty(value = "教育背景(0:高中;1:大专;2:本科)")
    private Integer educationType;

    /**
     * 任职要求
     */
    @ApiModelProperty(value = "任职要求")
    private String jobRequirement;

    /**
     * 岗位职责
     */
    @ApiModelProperty(value = "岗位职责")
    private String jobResponsibility;

    /**
     * 补贴金额
     */
    @ApiModelProperty(value = "补贴金额")
    private Integer subsidy;

    /**
     * 工资结算类型(0:日结;1:周结;2:月结;3:洗手拿钱)
     */
    @ApiModelProperty(value = "工资结算类型(0:日结;1:周结;2:月结;3:洗手拿钱)")
    private Integer settleAccountType;

    /**
     * 兼职工期类型(0:无;1:短期;2:长期)
     */
    @ApiModelProperty(value = "兼职工期类型(0:无;1:短期;2:长期)")
    private Integer partTimeType;

    /**
     * 工期(天)
     */
    @ApiModelProperty(value = "工期(天)")
    private Integer workDays;

    /**
     * 其他信息/备注
     */
    @ApiModelProperty(value = "其他信息/备注")
    private String remark;

    /**
     * 照片信息(多张照片按照逗号分割)
     */
    @ApiModelProperty(value = "照片信息(多张照片按照逗号分割)")
    private String picture;

    /**
     * 视频信息(多个视频按照视频分割)
     */
    @ApiModelProperty(value = "视频信息(多个视频按照视频分割)")
    private String video;

    @ApiModelProperty(value = "置顶状态(0:否;1:置顶)")
    private Integer topStatus;

    private Long updateDate;

    public static List<PositionVo> positionList(List<BossPosition> templateList) {
        return templateList.stream()
                .map(BossPositionDetailVo::positionVoList)
                .sorted(Comparator.comparing(PositionVo::getUpdateDate)
                        .reversed()
                        .thenComparing(PositionVo::getTopStatus)
                        .reversed())
                .collect(Collectors.toList());
    }


    private static PositionVo positionVoList(BossPosition position) {
        PositionVo vo = new PositionVo();
        vo.setId(position.getId());
        vo.setPositionName(position.getPositionName());
        vo.setPeopleNum(position.getPeopleNum());
        vo.setType(position.getType());
        vo.setPublishDate(position.getCreateDate().getTime());
        vo.setTopStatus(position.getTopStatus());
        vo.setUpdateDate(position.getUpdateDate().getTime());
        return vo;
    }

    public static BossPositionDetailVo detail(BossPosition template) {
        BossPositionDetailVo vo = new BossPositionDetailVo();
        vo.setId(template.getId());
        vo.setPositionName(template.getPositionName());
        vo.setStatus(template.getStatus());
        vo.setType(template.getType());
        vo.setPeopleNum(template.getPeopleNum());
        vo.setStartTime(template.getStartTime()
                .getTime());
        vo.setEndTime(template.getEndTime()
                .getTime());
        vo.setWorkTimeType(template.getWorkTimeType());
        vo.setSalaryType(template.getSalaryType());
        vo.setSalary(template.getSalary());
        vo.setMaxSalary(template.getMaxSalary());
        vo.setWorkHour(template.getWorkHour());
        vo.setBenefits(template.getBenefits());
        vo.setSex(template.getSex());
        vo.setMinAge(template.getMinAge());
        vo.setMaxAge(template.getMaxAge());
        vo.setEducationType(template.getEducationType());
        vo.setJobRequirement(template.getJobRequirement());
        vo.setJobResponsibility(template.getJobResponsibility());
        vo.setSubsidy(template.getSubsidy());
        vo.setSettleAccountType(template.getSettleAccountType());
        vo.setPartTimeType(template.getPartTimeType());
        vo.setWorkDays(template.getWorkDays());
        vo.setRemark(template.getRemark());
        vo.setPicture(template.getPicture());
        vo.setTopStatus(template.getTopStatus());
        vo.setVideo(template.getVideo());
        vo.setUpdateDate(template.getUpdateDate().getTime());
        return vo;
    }

    public static List<PositionListVo> recruitmentList(List<BossPosition> templateList) {
        return templateList.stream()
                .map(position -> {
                    PositionListVo vo = new PositionListVo();
                    vo.setId(position.getId());
                    vo.setPositionName(position.getPositionName());
                    vo.setPeopleNum(position.getPeopleNum());
                    vo.setType(position.getType());
                    vo.setPublishDate(position.getCreateDate().getTime());
                    vo.setTopStatus(position.getTopStatus());
                    vo.setUpdateDate(position.getUpdateDate().getTime());
                    vo.setApplyNumber(position.getApplyNumber());
                    vo.setInterviewNumber(position.getInterviewNumber());
                    vo.setMemberNumber(position.getMemberNumber());
                    return vo;
                })
                .collect(Collectors.toList());
    }
}
